package 面试.遍历算法.希尔排序练习;

public class 希尔排序01 {
    public static void main(String[] args) {
        int[] arr = {7,4,3,9,6,5,3,4,21,23,52,12,86,23,34,15,25,16,867,92,82,223,123,556,234,12356,21312,643,12312,645,32421,12334,324,21,34,153,123312,42342};
        int gap = arr.length;
        while (gap>1){
            gap /= 2;
            for (int i = 0; i < arr.length - gap; i++) {
                int num = arr[i + gap];
                int j = i;
                while (num < arr[j]){
                    arr[j + gap] = arr[j];
                    j -= gap;
                    if(j < 0) break;
                }
                arr[j+gap] = num;
            }
        }
        for (int i : arr) {
            System.out.println(i);
        }
    }
}
